perm filename FUNARG[L70,TES] blob sn#009937 filedate 1972-06-27 generic text, type T, neo UTF8
00100	LISP70 PUBLIC VARIABLES
00200	
00300	The following scheme handles backtracking, monitoring, reference
00400	variable arguments, and funargs.  If some or all of these facilities
00500	are turned off, the compiler can generate better code.
00600	
00700	If X is declared a PUBLIC variable, or if it gets SETQ'd at run-time, then
00800	it has a PUBLIC property which points to the type VARIABLE entity X.  Compiled
00900	code accesses this entity directly.  The compiler (EVAL) must get 'X.PUBLIC
01000	to find the entity.  "X" from now on will mean the VARIABLE entity.
01100	
01200	The entity table cell for X is either a MOVEI VAL, <record address> or a
01300	UUO <record address> (the latter for monitoring).  The cell is XCTed to
01400	load the <record> address into VAL.
01500	
01600	A VARIABLE record has three cells as follows:
01700		VALUE		The descriptor of the current binding
01800	
01900		CONTEXT		The oldest context in which this binding existed
02000	
02100		FREER		The virtual P location of the freer binding
02200	
02300		The layout is:
02400			 ---------------
02500			|     VALUE     |
02600			|---------------|
02700			|CONTEXT|  FD	|
02800			|---------------|
02900			|  FB	|   0	|
03000			 ---------------
03100	where FB is the environment (stack block) number and FD is the displacement
03200	within that environment.  If FB is negative, there is no freer binding in
03300	this context.  If FB = register ENV (the current stack block), then this
03400	VALUE is current; otherwise a search is necessary to see if it is really
03500	current and if not what binding is.  Note that in simple programs ENV=FB=CONTEXT=0.
03600	Then only the VALUE cell is needed.  If MONITORING is turned off, the
03700	VALUE can be directly in the entity table.
03800	
03900	
04000	LISP70 has an ALIST which consists of a list of landmarks in the P stack.
04100	ALIST is saved at decision points.  Its form is:
04200	
04300		(P1 Q1 P2 Q2 ... Pn Qn)
04400	
04500	The meaning is: "Those portions of the P stack that are currently accessible
04600	are 0 to Qn, Pn to Pn-1, .. P3 to Q2, P2 to Q1, and P1 to P."  "0" and "P"
04700	are the virtual bottom and top of the P stack.  Note that if the whole
04800	P stack is accessible, ALIST=NIL.
04900	
05000	To find the current value of a public variable X, call (SETTING (QUOTE X)).
05100	To change its current value to E, call (SET (QUOTE X) E).
05200	
05300	function setting(atomic v) =
05400		if freer(v) = unboundflag then error("unbound variable " cat v)
05500		else if accessible(freer(v), alist) then value(v)
05600		else setting(freer(v)) ;
05700	
05800	function accessible(f, a) =
05900		¬a ∨ (f > car a) ∨ (f ≤ cadr a ∧ accessible(f, cddr a)) ;
06000	
06100	function set(atomic v, e) =
06200		if freer(v) = unboundflag then bind(v, e)
06300		else if accessible(freer(v), alist) then place(value(v), e)
06400		else set(freer(v), e) ;
     

00100	TIMING INFORMATION
00200	
00300			Fetch Time / Store Time in microseconds
00400	
00500		PRIVATE VARIABLES:	4 / 4
00600	
00700		PUBLIC VARIABLES (if no FUNARG call or REF access being executed):
00800	
00900			DEBUG MODE: 31 / 31*
01000			PRODUCTION MODE (add 3 to FETCH if no GLOBAL declaration):
01100					SUBMODE →→→	BACKTRACKING
01200					  ↓↓↓		NO	 YES
01300					FUNREF	-  NO	5/5	 5/8*
01400						- YES	8/8	 8/10*
01500		   (*) Longer if first store in this context.
01600	
01700	The FUNREF submode allows FUNARGS and REF variables to be passed.
01800	The BACKTRACKING submode allows the use of CHOICE, SELECT, FAIL,
01900		SUSPEND, Rewrite rules, and VALFUNARGS.
02000	
02100	The slowness in debugging mode is due to the 20 mics UUO overhead:
02200		UUO PUSHJ LDB JRST POPJ
02300	
02400	If the atom X or the public variable X is being monitored, then accesses
02500	to X are slower.  If the private variable P is being monitored, then
02600	accesses to P are slower.
02700	
02800	If the compiler is fetching to a register instead of the stack, all
02900	fetches in PRODUCTION mode are 2 mics faster.
03000	
03100	If a special case store such as X←X+1 or X←0, it is faster.